-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] Week4 필수 과제 #9
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4주차 과제도 고생하셨습니다 ~~
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UserSignUpRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dto 네이밍 형식을 서로 맞춰주면 좋을 것 같아요!
fun Context.toast(message: String) { | ||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toast 확장함수 추가 좋네요!
password = password | ||
), | ||
) { body -> | ||
editor.putString("loginToken", body!!.result.token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 스트링 추출 해볼까요!
fun postUserLogin( | ||
context: Context, | ||
body: UserLoginRequest, | ||
callback: (ResponseUserTokenDto?) -> Unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback이 필요한 이유가 혹시 무엇일까요?? 중복된 로직을 제공한다면 불필요할 것 같아요!
val error = response.message() | ||
Log.e("error", error.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
분기에 따른 에러 메시지가 보여지면 좋을 것 같아요! 지금은 로그인 실패 시 모두 fail_to_login 토스트 메시지가 뜨는 것 같아요!
viewModel: MyViewModel = viewModel() | ||
) { | ||
val context = LocalContext.current | ||
val snackbarHostState = remember { SnackbarHostState() } | ||
val sharedPreferences = context.getSharedPreferences("token", Context.MODE_PRIVATE) | ||
val token = sharedPreferences.getString("loginToken", "").orEmpty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orEmpty를 붙여주셨군요!
if (response.isSuccessful) { | ||
_userState.value = response.body() | ||
_hobby.value = response.body()?.result?.hobby | ||
Log.d("getUserHobby", response.body().toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로그는 확인 후 지워줍시당 ! Timber를 활용해봐도 좋을 것 같아요 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전반적으로 잘 짜주신 것 같아요! 근데 함수의 Depth가 길어지거나 분기처리가 많아질 경우에 좀 더 분리가 잘 되어 보이게 수정하면 더 좋을 것 같습니다!
.addInterceptor(loggingInterceptor) | ||
.build() | ||
|
||
val retrofit: Retrofit by lazy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lazy 하게 설정한 것 좋은 것 같아요!
.build() | ||
} | ||
|
||
inline fun <reified T> create(): T = retrofit.create(T::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음 보는 코드여서 어떤 코드인지 찾아봤는데 재사용성이 더 좋아진다고하니 좋은 코드인 것 같아요~!
@@ -184,16 +176,19 @@ fun LoginScreen( | |||
WavveLoginButton( | |||
onClick = { | |||
viewModel.onLoginClick( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
viewModel의 함수가 중첩돼서 가시성이 조금 떨어지는 것 같아요!
두개 함수를 조금 분리해서 파라미터로 넘기는 방식도 생각해봐주세요!
LaunchedEffect(Unit) { | ||
snackbarHostState.showSnackbar(context.getString(R.string.welcome)) | ||
} | ||
viewModel.getUserHobby(token = token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
직접 실행하는 방법도 좋은데 LaunchedEffect(Unit)
을 사용해서 한 번만 불러오는 방법도 생각해주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 하면 리컴포지션시마다 계속 서버 통신 함수를 부르게 될 것 같네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생했서요! 합동 세미나도 파이팅!!!
data class ResponseUserHobbyDto( | ||
@SerialName("result") | ||
val result: Result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
형태가 계속 반복되니 baseResponse를 사용해봐도 좋을 듯 합니다.
val dispatcher = LocalOnBackPressedDispatcherOwner.current!!.onBackPressedDispatcher | ||
val sharedPreferences = context.getSharedPreferences("token", Context.MODE_PRIVATE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! 사용은 지양합시다 NPE가 발생할 수 있서요
LaunchedEffect(Unit) { | ||
snackbarHostState.showSnackbar(context.getString(R.string.welcome)) | ||
} | ||
viewModel.getUserHobby(token = token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 하면 리컴포지션시마다 계속 서버 통신 함수를 부르게 될 것 같네요!
Related issue 🛠
Work Description ✏️
회원가입
로그인
내 취미 조회
Screenshot 📸
Screen_recording_20241114_222915.mp4
Uncompleted Tasks 😅
To Reviewers 📢
피드백 뭐든지 환영합니당